{% extends 'basepl.html' %}
{% load static %}

{% block head %}
    <title>查看学生名单/成绩</title>
    <style>
    #roll{
            position: absolute;
            padding-right:10px;
            overflow-y:auto;
            padding-left:10px;
            SCROLLBAR-FACE-COLOR:#ffffff;
            font-size:11pt;
            padding-bottom:0;
            scrollbar-highlight-color:#ffffff;
            scrollbar-shadow-color:#919192;
            color:black;
            scrollbar-3dlight-color:#ffffff;
            line-height:100%;
            scrollbar-arrow-color:#919192;
            padding-top:0;
            scrollbar-track-color:#ffffff;
            font-family: 宋体;
            scrollbar-darkshadow-color:#ffffff;
            letter-spacing:1pt;
            height:580px;
            width: 980px;
            top: 20px;
            left:100px ;
            align-items: center;
    }
    section{
        border: gray solid;
    }

    #certain1{
        top: 20px;
        left: 20px;
        display: block;
        width: 80px;
        background: rgba(177, 19, 226, 0.4);
       position: absolute;
    }
    </style>
{% endblock head %}
{% block nav %}
<li><a href="/stuIndex">首页</a></li>
<li><a href="#top">大学课程教学过程管理系统</a></li>
<li><a href="/">切换账号</a></li>
<li><a href="#"></a></li>
<li><a href="#">关于</a></li>
<li><a href="/">注销</a></li>
{% endblock %}
{% block li %}
<li><a href="#">课&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;程</a></li>
<li><a href="/stuIndex/stuGrade">成&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;绩</a></li>
<li><a href="/stuIndex/xuanke">选&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;课</a></li>
{% endblock li %}

{% block section %}
<div id="roll">
<h4></h4>
<table border="1px" align="center">
    <tr><th colspan="5">已选课程</th></tr>
    <tr>
    <th width="100px" >课程号</th>
    <th width="100px" >课程</th>
    <th width="100px" >大纲</th>
    <th width="400px" >详细</th>
    <th width="100px" >教师</th>
    {% for c in courses %}
        <tr>
            <td align="center">{{ c.cnum_id }}</td>
            <td align="center">{{ c.cnum.cname}}</td>
            <td align="center">{{ c.cnum.dagang }}</td>
            <td align="center">
                <table  border="0" cellpadding="5px">
                    {% for d in c.cnum.teaproc_set.all %}
                        <tr>
                            <td class="{{ d.id }}"><input id="check" type="checkbox">{{ d.id }}</td>
                            <td>周{{ d.week }}</td>
                            <td>第{{ d.part }}大节</td>
                            <td>{{ d.pos }}</td>
                        </tr>
                    {% endfor %}
                </table>

            </td>
            <td align="center">{{ c.cnum.tname}}</td>

        </tr>
    {% endfor %}
</table>
</div>
<a id="certain1" href="#" onclick="ctb()">确定选课</a>
<script src="{% static '/jquery.min.js' %}"></script>
<script>
    var str='ctable?pid=';
    var pre=str.length;
    $(':checkbox').click(function () {
        if ($(this).prop('checked')) {
            var id = $(this).parent().text();
            str = str + id + '_'
        }
    });
    function ctb() {
        if (str.length >pre) {
            str = str.substring(0, str.length-1);
            $.get(str,function (data) {
                if(data.flag)
                    alert('有重复课程，已覆盖！');
                else alert('添加成功！')
            });
        }
        str='ctable?pid=';
    }
</script>

{% endblock section %}

